package com.zhiqianbao.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.zhiqianbao.R;

/**
 * Created by hp on 2017/10/12.
 */
public class ProcessProgressBarView extends LinearLayout{
    public static final int IS_SHOW_ZHIMA=1;
    public static final int NOTIS_SHOW_ZHIMA=2;
    LinearLayout ll_progress1;
    ImageView first_iv1;
    ImageView second_iv1;
    ImageView third_iv1;
    ImageView fourth_iv1;
    ImageView fiveth_iv1;
    LinearLayout ll_progress2;
    ImageView first_iv2;
    ImageView second_iv2;
    ImageView third_iv2;
    ImageView fourth_iv2;
    public ProcessProgressBarView(Context context) {
        super(context);
        initView(context);
    }

    public ProcessProgressBarView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    public ProcessProgressBarView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
    }

    public void initView(Context context){
        View processView= LayoutInflater.from(context).inflate(R.layout.process_progressbar_layout,this);
        ll_progress1=(LinearLayout)processView.findViewById(R.id.ll_progress0);
        first_iv1=(ImageView)processView.findViewById(R.id.first_iv0);
        second_iv1=(ImageView)processView.findViewById(R.id.second_iv0);
        third_iv1=(ImageView)processView.findViewById(R.id.third_iv0);
        fourth_iv1=(ImageView)processView.findViewById(R.id.fourth_iv0);
        fiveth_iv1=(ImageView)processView.findViewById(R.id.fiveth_iv0);
        ll_progress2=(LinearLayout)processView.findViewById(R.id.ll_progress2);
        first_iv2=(ImageView)processView.findViewById(R.id.first_iv2);
        second_iv2=(ImageView)processView.findViewById(R.id.second_iv2);
        third_iv2=(ImageView)processView.findViewById(R.id.third_iv2);
        fourth_iv2=(ImageView)processView.findViewById(R.id.fourth_iv2);
    }

    public void openZhiMaProcess(int type,int processProgress){
        if(type==IS_SHOW_ZHIMA){
            ll_progress1.setVisibility(View.VISIBLE);
            ll_progress2.setVisibility(View.GONE);
            switch (processProgress){
                case 1:
                    first_iv1.setImageResource(R.drawable.alreadywan);
                    break;
                case 2:
                    first_iv1.setImageResource(R.drawable.alreadywan);
                    second_iv1.setImageResource(R.drawable.alreadywan);
                    break;
                case 3:
                    first_iv1.setImageResource(R.drawable.alreadywan);
                    second_iv1.setImageResource(R.drawable.alreadywan);
                    third_iv1.setImageResource(R.drawable.alreadywan);
                    break;
                case 4:
                    first_iv1.setImageResource(R.drawable.alreadywan);
                    second_iv1.setImageResource(R.drawable.alreadywan);
                    third_iv1.setImageResource(R.drawable.alreadywan);
                    fourth_iv1.setImageResource(R.drawable.alreadywan);
                    break;
                case 5:
                    first_iv1.setImageResource(R.drawable.alreadywan);
                    second_iv1.setImageResource(R.drawable.alreadywan);
                    third_iv1.setImageResource(R.drawable.alreadywan);
                    fourth_iv1.setImageResource(R.drawable.alreadywan);
                    fiveth_iv1.setImageResource(R.drawable.alreadywan);
                    break;
            }
        }
        else{
            ll_progress1.setVisibility(View.GONE);
            ll_progress2.setVisibility(View.VISIBLE);
            switch (processProgress){
                case 1:
                    first_iv2.setImageResource(R.drawable.alreadywan);
                    break;
                case 2:
                    first_iv2.setImageResource(R.drawable.alreadywan);
                    second_iv2.setImageResource(R.drawable.alreadywan);
                    break;
                case 3:
                    first_iv2.setImageResource(R.drawable.alreadywan);
                    second_iv2.setImageResource(R.drawable.alreadywan);
                    third_iv2.setImageResource(R.drawable.alreadywan);
                    break;
                case 4:
                    first_iv2.setImageResource(R.drawable.alreadywan);
                    second_iv2.setImageResource(R.drawable.alreadywan);
                    third_iv2.setImageResource(R.drawable.alreadywan);
                    fourth_iv2.setImageResource(R.drawable.alreadywan);
                    break;
            }
        }
    }
}
